home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / InvisibleHTMLLinkBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  7KB  |  220 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/07/97    LAB    Fixed misspelling of descriptions.
  8. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  9.  
  10. /**
  11.  * BeanInfo for InvisibleHTMLLink.
  12.  *
  13.  */
  14. public class InvisibleHTMLLinkBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a InvisibleHTMLLinkBeanInfo object.
  18.      */
  19.     public InvisibleHTMLLinkBeanInfo() {
  20.     }
  21.  
  22.     /**
  23.      * Gets a BeanInfo for the superclass of this bean.
  24.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  25.      */
  26.     public BeanInfo[] getAdditionalBeanInfo() {
  27.         try {
  28.             BeanInfo[] bi = new BeanInfo[1];
  29.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  30.             return bi;
  31.         }
  32.         catch (IntrospectionException e) { throw new Error(e.toString());}
  33.     }
  34.  
  35.     /**
  36.      * Gets the SymantecBeanDescriptor for this bean.
  37.      * @return an object of type SymantecBeanDescriptor
  38.      * @see symantec.itools.beans.SymantecBeanDescriptor
  39.      */
  40.     public BeanDescriptor getBeanDescriptor() {
  41.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  42.         String s=group.getString("GroupAWTAdditions"); 
  43.  
  44.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  45.         bd.setWinHelp("0x12392");
  46.         bd.setFolder(s);
  47.         bd.setToolbar(s);
  48.  
  49.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  50.         s=conn.getString("currentFrame"); 
  51.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "String", "",
  52.                                                 "\"_self\"",s));
  53.  
  54.         s=conn.getString("parentFrame"); 
  55.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "String", "",
  56.                                                 "\"_parent\"",s));
  57.  
  58.         s=conn.getString("topmostFrame"); 
  59.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "String", "",
  60.                                                 "\"_top\"",s));
  61.  
  62.         s=conn.getString("unnamedFrame"); 
  63.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "String", "",
  64.                                                 "\"_blank\"",s));
  65.  
  66.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  67.  
  68.         return (BeanDescriptor) bd;
  69.     }
  70.  
  71.     /**
  72.      * Gets an image that may be used to visually represent this bean
  73.      * (in the toolbar, on a form, etc).
  74.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  75.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  76.      * @return an image for this bean, always color even if requested monochrome
  77.      * @see BeanInfo#ICON_MONO_16x16
  78.      * @see BeanInfo#ICON_COLOR_16x16
  79.      * @see BeanInfo#ICON_MONO_32x32
  80.      * @see BeanInfo#ICON_COLOR_32x32
  81.      */
  82.     public java.awt.Image getIcon(int iconKind) {
  83.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  84.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  85.             java.awt.Image img = loadImage("InvisibleHTMLLinkC16.gif");
  86.             return img;
  87.         }
  88.  
  89.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  90.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  91.             java.awt.Image img = loadImage("InvisibleHTMLLinkC32.gif");
  92.             return img;
  93.         }
  94.  
  95.         return null;
  96.     }
  97.  
  98.     /**
  99.      * Gets an array of descriptions of the methods used for "connections" by
  100.      * Visual CafΘ's Interaction Wizard.
  101.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  102.      * @return method descriptions for this bean
  103.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  104.      */
  105.     public MethodDescriptor[] getMethodDescriptors() {
  106.         Class[] args;
  107.         ConnectionDescriptor connection;
  108.         java.util.Vector connections;
  109.         java.util.Vector md = new java.util.Vector();
  110.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  111.         String s;
  112.  
  113.         try{
  114.             args = null;
  115.             MethodDescriptor getURL = new MethodDescriptor(beanClass.getMethod("getURL", args));
  116.  
  117.             connections = new java.util.Vector();
  118.             s=conn.getString("getURL"); 
  119.             connection = new ConnectionDescriptor("output", "URL", "",
  120.                                     "%name%.getURL()",s);
  121.             connections.addElement(connection);
  122.  
  123.             getURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  124.             md.addElement(getURL);
  125.         } catch (Exception e) { throw new Error("getURL:: " + e.toString()); }
  126.  
  127.         try{
  128.             args = new Class[1];
  129.             args[0] = java.net.URL.class ;
  130.             MethodDescriptor setURL = new MethodDescriptor(beanClass.getMethod("setURL", args));
  131.  
  132.             connections = new java.util.Vector();
  133.             s=conn.getString("setURLRelative"); 
  134.             connection = new ConnectionDescriptor("input", "RelativeURL", "",
  135.                                     "%name%.setURL(symantec.itools.net.RelativeURL.getURL(%arg%));",s);
  136.             connections.addElement(connection);
  137.  
  138.             s=conn.getString("setURL"); 
  139.             connection = new ConnectionDescriptor("input", "URL", "",
  140.                                     "%name%.setURL(%arg%);",s);
  141.             connections.addElement(connection);
  142.  
  143.             setURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  144.             md.addElement(setURL);
  145.         } catch (Exception e) { throw new Error("setURL:: " + e.toString()); }
  146.  
  147.         try{
  148.             args = new Class[1];
  149.             args[0] = java.lang.String.class ;
  150.             MethodDescriptor setFrame = new MethodDescriptor(beanClass.getMethod("setFrame", args));
  151.  
  152.             connections = new java.util.Vector();
  153.             s=conn.getString("setFrame"); 
  154.             connection = new ConnectionDescriptor("input", "String", "",
  155.                                     "%name%.setFrame(%arg%);",s);
  156.             connections.addElement(connection);
  157.  
  158.             setFrame.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  159.             md.addElement(setFrame);
  160.         } catch (Exception e) { throw new Error("setFrame:: " + e.toString()); }
  161.  
  162.         try{
  163.             args = null;
  164.             MethodDescriptor getFrame = new MethodDescriptor(beanClass.getMethod("getFrame", args));
  165.  
  166.             connections = new java.util.Vector();
  167.             s=conn.getString("getFrame"); 
  168.             connection = new ConnectionDescriptor("output", "String", "",
  169.                                     "%name%.getFrame()",s);
  170.             connections.addElement(connection);
  171.  
  172.             getFrame.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  173.             md.addElement(getFrame);
  174.         } catch (Exception e) { throw new Error("getFrame:: " + e.toString()); }
  175.  
  176.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  177.         md.copyInto(rv);
  178.  
  179.         return rv;
  180.     }
  181.  
  182.     /**
  183.      * Returns descriptions of this bean's properties.
  184.      */
  185.     public PropertyDescriptor[] getPropertyDescriptors() {
  186.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  187.         String s;
  188.  
  189.         try{
  190.         PropertyDescriptor defProperty = new PropertyDescriptor("uRL", beanClass);
  191.         defProperty.setBound(true);
  192.         defProperty.setConstrained(true);
  193.         s=prop.getString("linkURL"); 
  194.         defProperty.setDisplayName(s);
  195.         s=prop.getString("htmlURLFILTER"); 
  196.         defProperty.setValue("URLFILTER", s);
  197.  
  198.         PropertyDescriptor frame = new PropertyDescriptor("frame", beanClass);
  199.         frame.setBound(true);
  200.         frame.setConstrained(true);
  201.         s=prop.getString("frame"); 
  202.         frame.setDisplayName(s);
  203.  
  204.         PropertyDescriptor[] rv = {
  205.             defProperty,
  206.             frame};
  207.         return rv;
  208.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  209.     }
  210.  
  211.     /**
  212.      * Returns the index of the property expected to be changed most often by the designer.
  213.      */
  214.     public int getDefaultPropertyIndex() {
  215.         return 0;    //  the index for our default property is always 0
  216.     }
  217.  
  218.     private final static Class beanClass = InvisibleHTMLLink.class;
  219.  
  220.     }    //  end of class InvisibleHTMLLinkBeanInfo